<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
    />
    <title>贪吃蛇游戏</title>
    <style>
      body {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        margin: 0;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      }

      #game-container {
        display: flex;
        flex-direction: column;
        gap: 20px;
        background-color: rgba(255, 255, 255, 0.3);
        padding: 20px;
        border-radius: 15px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(5px);
        width: 90%;
        max-width: 400px;
        margin: auto;
      }

      canvas {
        border: 4px solid #333;
        background-color: #222;
        border-radius: 10px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
        position: relative;
        transition: transform 0.3s ease;
        width: 100%;
        height: auto;
      }

      canvas:hover {
        transform: scale(1.02);
      }

      canvas::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: linear-gradient(
            rgba(255, 255, 255, 0.05) 1px,
            transparent 1px
          ),
          linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
        background-size: 20px 20px;
        border-radius: 10px;
      }

      #controls {
        margin-bottom: 20px;
        display: flex;
        gap: 10px;
        align-items: center;
        justify-content: center;
      }

      #startButton {
        padding: 10px 20px;
        background-color: #4caf50;
        color: white;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        transition:
          background-color 0.3s ease,
          transform 0.3s ease;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
      }

      #startButton:hover {
        background-color: #45a049;
        transform: scale(1.05);
      }

      #difficulty {
        padding: 10px 30px 10px 10px;
        border: none;
        border-radius: 5px;
        background-color: white;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
        background-repeat: no-repeat;
        background-position: right 10px center;
        background-size: 15px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        transition: transform 0.3s ease;
      }

      #difficulty:hover {
        transform: scale(1.05);
      }

      #difficulty option {
        text-align: center;
      }

      #leaderboard {
        font-size: 1em;
        background-color: rgba(255, 255, 255, 0.8);
        padding: 15px;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        min-width: 150px;
        transition: transform 0.3s ease;
      }

      #leaderboard:hover {
        transform: scale(1.02);
      }

      #leaderboard h3 {
        margin: 0 0 10px 0;
        color: #333;
        text-align: center;
      }

      #leaderboard ul {
        list-style: none;
        padding: 0;
        overflow: auto;
        height: 115px;
      }

      #leaderboard li {
        margin: 5px 0;
        padding: 5px;
        border-bottom: 1px solid #ddd;
        transition: background-color 0.3s ease;
      }

      #leaderboard li:hover {
        background-color: #f0f0f0;
      }

      #leaderboard li:last-child {
        border-bottom: none;
      }
    </style>
  </head>

  <body>
    <div id="game-container">
      <div>
        <div id="controls">
          <button id="startButton">开始游戏</button>
          <label for="difficulty">难度：</label>
          <select id="difficulty">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
          </select>
        </div>
        <canvas id="gameCanvas" width="400" height="400"></canvas>
      </div>
      <div id="leaderboard">
        <h3>排行榜</h3>
        <ul id="leaderboardList"></ul>
      </div>
    </div>
    <script src="game.js"></script>
  </body>
</html>
